//
//  HomeViewController+LoadData.m
//  JKFuYinProject
//
//  Created by admin on 2018/1/5.
//  Copyright © 2018年 LC. All rights reserved.
//

#import "HomeViewController+LoadData.h"

@implementation HomeViewController (LoadData)

-(void)loadChannelData{
    YYCache *yyCache=[YYCache cacheWithName:@"LCHomeChannelName"];
    if ([yyCache containsObjectForKey:@"keyHomeChannel"]) {
        id vuale = [yyCache objectForKey:@"keyHomeChannel"];
        self.array = [NSArray yy_modelArrayWithClass:[ChannelModel class] json:vuale];
        [self.tabBarContentView reloadData];
    }
    [ChannelModel getNewsCateWithSuccBlock:^(NSArray<ChannelModel *> *modelArr) {
        if (self.array.count == modelArr.count) {
            BOOL isOK = NO;
            for (NSInteger i = 0; i < modelArr.count; i++) {
                if ([self.array[i].cate isEqualToString:modelArr[i].cate] && [self.array[i].id isEqualToString:modelArr[i].id]) {
                    isOK = YES;
                }else{
                    isOK = NO;
                    break;
                }
            }
            if (isOK == NO/**假如和缓存的标签中title且id不一致就刷新*/) {
                self.array = modelArr;
                [self.tabBarContentView reloadData];
            }
        }else{
            self.array = modelArr;
            [self.tabBarContentView reloadData];
        }
    }];
}

@end
